﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AdLocation : TJLogger{

	private AndroidJavaObject jo;

	public enum AdLocState
	{
		UnUse,
		UnInit,
		Open,
		Close
	}
	private AdLocState adLocState = AdLocState.UnInit;

	public void Init (string key)
	{
		if (jo == null) {
			jo = new AndroidJavaObject ("com.location.Main");
			jo.CallStatic ("setCallBack", "TJSDK", "OnADLocCallBack");
			jo.CallStatic("init",key);
		}
	}

	/// 广告开关回调方法
	public void OnADLocCallBack(string result){
		TJLog ("广告开关回调：" + result);
		switch (result) {
		case "on":			adLocState = AdLocState.Open; 			break;
		case "off": 		adLocState = AdLocState.Close; 			break;
		case "error": 		adLocState = AdLocState.Close; 			break;
		default: 			adLocState = AdLocState.Close; 			break;
		}
		TJLog ("广告开关回调：" + adLocState.ToString());
	}

	public AdLocState GetAdLocState(){
		return adLocState;
	}

}
